package com.gfxy.modules;

import com.auth0.jwt.JWT;
import com.auth0.jwt.interfaces.DecodedJWT;

import javax.servlet.http.HttpServletRequest;

/**
 * @author: lijixin 2021/9/24 5:46 下午
 */
public class GfxyUtils {

    public static String getRoles(HttpServletRequest request){
        String accessToken = request.getHeader("X-Access-Token");
        DecodedJWT jwt = JWT.decode(accessToken);
        String rolesStr = jwt.getClaim("rolesSet").asString();
        return rolesStr;
    }

    public static String getOrgCode(HttpServletRequest request){
        String accessToken = request.getHeader("X-Access-Token");
        DecodedJWT jwt = JWT.decode(accessToken);
        String orgCode = jwt.getClaim("orgCode").asString();
        return orgCode;
    }
}
